package cn.yunhe.servlet;

import cn.yunhe.dao.IFoodDaoMapper;
import cn.yunhe.dao.ITypeDaoMapper;
import cn.yunhe.entity.merchantsentity.Food;
import cn.yunhe.entity.merchantsentity.Type;
import cn.yunhe.services.GetFoodIdService;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 周依博
 *
 * 菜品编辑跳转的servlet
 * 获得需要编辑的菜品id，遍历这行信息
 * @param
 * @return
 */
@WebServlet("/shangjia/GetFoodIdServlet")
public class GetFoodIdServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            int foodid= Integer.parseInt(request.getParameter("foodid"));
            int typeid= Integer.parseInt(request.getParameter("typeid"));
        GetFoodIdService getFoodIdService = new GetFoodIdService();

            request.setAttribute("typeList",getFoodIdService.getAllType());
            request.setAttribute("typeid",typeid);
            request.setAttribute("food",getFoodIdService.getNewsById(foodid));
            request.getRequestDispatcher("product-add2.jsp").forward(request,response);

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
